import random

class Solution:

    def _get_unicode(self, num):
        # 繁体字
        s = ''
        for i in range(int(num)):
            val = random.randint(0x4e00, 0x9fbf)
            s +=  chr(val)
        print(s)
        return s


    def get_gbk(self,num):
        # 简体中文
        s = ''
        for i in range(int(num)):
            head = random.randint(0xb0, 0xf7)
            body = random.randint(0xa1, 0xfe)
            val = f'{head:x} {body:x}'
            s  += bytes.fromhex(val).decode('gb2312')
        print(s)
        return s

    def get_en(self,num):
        #26 个英文字母大小写
        list1 = list(map(lambda x:str(chr(x)),range(ord('A'),ord('Z')+1))) +list(map(lambda x:str(chr(x)),range(ord('a'),ord('z')+1)))
        res = ''.join(random.sample(list1,num))
        print(res)
        return  res


    def _judge_num(self,num):
        if not num.isdigit():
            return False
        return True

    def get_num(self,num):
        first = str(random.randint(1,9))
        res = first+"".join([str(random.randint(0,9)) for i in range(int(num)-1)])
        print(res)
        return res

    def run(self):
        while True :
            num = input(
'''
|------------|
|请选择选项：  |
|1.汉字       |
|2.英文字母    |
|3.数字       |
|------------|
'''
            )
            if not self._judge_num(num):
                res = input('输入非法，是否继续  Y/N :')
                if res == 'Y':
                    continue
                else:
                    return
            elif num not in ('1', '2','3'):
                   print('请输入正确数字')
                   continue
            else:
                while True:
                    num2= input("请输入需要的长度(0可视为结束):")
                    if not self._judge_num(num2):
                        #非正整数
                        res = input('输入非法，是否继续  Y/N :')
                        if res == 'Y':
                            continue
                        else:
                            break
                    if num2 == '0' :
                        break
                    elif num == "1":
                        self.get_gbk(int(num2))
                    #   self.get_unicode(int(num))
                    elif num == "2":
                        self.get_en(int(num2))
                    elif num == "3":
                        self.get_num(num2)





if __name__ == '__main__':
    s = Solution()
    s.run()

